// drawBall(200,200,200,"#ff0000");
// drawRect(100,100,100,100,6,"#ff0000");

/**
 * 绘制一个矩形边框，用来表示建筑的边界
 * @param context
 * @param x
 * @param y
 * @param w
 * @param h
 * @param width
 * @param color
 */
function drawRect(context,x,y,w,h,width,color){
    context.beginPath();
    context.lineWidth = width;
    context.strokeStyle = color;
    context.strokeRect(x,y,w,h);
    context.closePath();
}
// 绘制一个小球
function drawBall(context,x,y,r,lineWidth,lienColor,fillColor){
    context.beginPath();
    context.lineWidth = lineWidth;
    // context.lineStyle = lienColor;
    context.strokeStyle = lienColor;
    context.arc(x,y,r,0,2*Math.PI,true);
    context.stroke();
    context.beginPath();
    context.arc(x,y,r,0,Math.PI*2,true);
    context.fillStyle = fillColor;
    context.fill();
    // context.flush();
}

/**
 * 绘制文字
 * @param context canvas 画笔
 * @param text 文字内容
 * @param x 坐标x
 * @param y 坐标y
 * @param font 字体
 * @param color 颜色
 */
function drawText(context,text,x,y,font,color){
    context.beginPath();
    context.font = font + "bold";
    // context.fo= "bold";
    context.testAlign = "center";
    context.fillStyle = color;
    context.fillText(text,x,y);
    context.closePath();
}

// ===========================================================
// 显示一名学生信息
function showStudentInfo(context,student){
    // 画圆
    // 参数 context,x,y,r,lineWidth,lienColor,fillColor
    drawBall(
        context,
        student.position.x,
        student.position.y,
        student.position.r,
        student.position.lineWidth,
        student.position.lienColor,
        student.position.fillColor
    );
    // 画文字
    // context,text,x,y,font,color
    drawText(
        context,
        student.id+'',
        student.position.x,
        student.position.y,
        'bold',
        student.position.textColor,
    )
}
// 显示一个建筑对象
function showBuildingInfo(context,building){
    // 绘制建筑边界  // context,x,y,w,h,width,color
    drawRect(
        context,
        building.position.beginX,
        building.position.beginY,
        building.position.w,
        building.position.h,
        building.position.lineWidth,
        building.position.color
        );
    // 绘制建筑中的文字  context,text,x,y,font,color
    drawText(
        context,
        building.name,
        building.position.centerX,
        building.position.centerY,
        '宋体',
        'block'
    );
}

export {drawRect,drawBall,drawText,showStudentInfo,showBuildingInfo};